//
//  FirstTabTableViewCell.m
//  marrymarry
//
//  Created by lsj on 16/9/13.
//  Copyright © 2016年 cf. All rights reserved.
//
#define JIANJU_Y 10
#define JIANJU_X 8
#define LABEL_MAXWIDTH 200
#import "FirstTabTableViewCell.h"
#import "HomeModel.h"
@implementation FirstTabTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)reloadTheCellWithIndexPath:(NSIndexPath *)indexPath andArray:(NSMutableArray *)dataArry andHadHeartArry:(NSMutableArray *)heartArry
{
    
    
    HomeModel * model = dataArry [indexPath.row];
    if ([heartArry containsObject:[NSNumber numberWithInt:[model.otherId intValue]]]) {
        [self.heartBtn setImage:[UIImage imageNamed:@"heartLight"] forState:UIControlStateNormal];
    }else{
        [self.heartBtn setImage:[UIImage imageNamed:@"heartBtn"] forState:UIControlStateNormal];
    }
        
    self.nameLabel.text = model.userName;
    self.wantedMTimLabel.text = model.homeMarryTime;
    self.simpleInfoLabel.text = [NSString stringWithFormat:@"%@岁 %@ %@ %@",model.birthday,model.height,model.incomeYear, model.startSign];
    NSString * placeStr = model.workCity;
    NSArray * placeArry = [placeStr componentsSeparatedByString:@" "];
    self.addressLabel.text = placeArry[0];
    [self.personImgView setImageWithURL:[NSURL URLWithString:model.facePhoto]];
    self.detialLabel.text = model.strength;
    
    UIFont * tfont = [UIFont systemFontOfSize:15];
    NSString * tstring = model.userName;
    CGSize size =CGSizeMake(LABEL_MAXWIDTH,20);
    NSDictionary * tdic = [NSDictionary dictionaryWithObjectsAndKeys:tfont,NSFontAttributeName,nil];
    CGSize  actualsize =[tstring boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin  attributes:tdic context:nil].size;
    self.nameLabel.frame =CGRectMake(8,8,actualsize.width, actualsize.height);
    self.RzimgView.frame = CGRectMake(15+self.nameLabel.frame.size.width,8, 21, 21);
    
    
    UIFont * wFont = [UIFont systemFontOfSize:13];
    NSString * wString = model.homeMarryTime;
    CGSize wSize = CGSizeMake(LABEL_MAXWIDTH,20);
    NSDictionary * wdic = [NSDictionary dictionaryWithObjectsAndKeys:wFont,NSFontAttributeName,nil];
    CGSize  wactualsize =[wString boundingRectWithSize:wSize options:NSStringDrawingUsesLineFragmentOrigin  attributes:wdic context:nil].size;
    self.wantedMTimLabel.frame = CGRectMake(ScreenWidth-8-wactualsize.width,8,wactualsize.width, wactualsize.height);
    self.wantMarriedImgView.frame = CGRectMake(self.wantedMTimLabel.frame.origin.x - 8, 10,13, 13);
    
    
    
    UIFont * dFont = [UIFont systemFontOfSize:12];
    NSString * dString = placeArry[0];
    CGSize dSize = CGSizeMake(LABEL_MAXWIDTH,20);
    NSDictionary * ddic = [NSDictionary dictionaryWithObjectsAndKeys:dFont,NSFontAttributeName,nil];
    CGSize  dactualsize =[dString boundingRectWithSize:dSize options:NSStringDrawingUsesLineFragmentOrigin  attributes:ddic context:nil].size;
    self.addressLabel.frame = CGRectMake(ScreenWidth-8-dactualsize.width,36,dactualsize.width, dactualsize.height);
    self.addressImgView.frame = CGRectMake(self.addressLabel.frame.origin.x-15, 36,13, 13);
    
   
    
    
    
    
    
}



- (IBAction)giftBtnSelect:(UIButton *)sender {
    NSLog(@"点击了礼物");
}

- (IBAction)heartBtnSelect:(UIButton *)sender {
    NSLog(@"点击了心动");
    
}

- (IBAction)chatBtnSelect:(UIButton *)sender {
    NSLog(@"点击了聊天");
}

- (IBAction)allInfoBtnSelect:(UIButton *)sender {
    NSLog(@"点击了全文");
}

@end
